home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14886 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: camelot.dsccc.com!kcline
  2. From: kcline@sun132.spd.dsccc.com (Kevin Cline)
  3. Newsgroups: comp.lang.ada,comp.lang.c++
  4. Subject: Re: some questions re. Ada/GNAT from a C++/GCC user
  5. Date: 2 Apr 1996 15:37:04 GMT
  6. Organization: DSC Communications Corporation Switch Products Division
  7. Message-ID: <4jrhj0$lqd@tpd.dsccc.com>
  8. References: <wnewmanDoxrCp.DKv@netcom.com> <Dp1oAw.7Cz@world.std.com> <4jlj79$h1k@Nntp1.mcs.net> <Dp75DK.DMG@world.std.com>
  9. NNTP-Posting-Host: sun132.spd.dsccc.com
  10.  
  11. In article <Dp75DK.DMG@world.std.com>,
  12. Robert A Duff <bobduff@world.std.com> wrote:
  13. >Well, I'm not sure exactly what you're asking.  To print stuff out, you
  14. >need some procedure that prints text strings, and you need some way to
  15. >convert whatever you want to print out into a text string.  In Ada,
  16. >'Image is used to convert simple data types like Integer and Float into
  17. >human-readable Strings.  For complicated data types, you write your own
  18. >Image function.  
  19.  
  20. This is a flaw in the Ada language design, IMHO.  Why should
  21. different methods be used to externalize primitive and user-defined types?
  22. It certainly makes program maintainence more difficult; imagine a change
  23. from
  24.  
  25.     type sequence_number_type is 0..2**32-1
  26.  
  27. to
  28.  
  29.     type sequence_number_type is 
  30.     record
  31.       time: time_type;
  32.       serial: 2**32-1;
  33.     end;
  34.  
  35. If this change was not anticipated then every use of 'IMAGE to
  36. output a sequence number must be changed to IMAGE().
  37.  
  38. >The "&" operator just concatenates Strings.  So to
  39. >print out some stuff, you write:
  40. >
  41. >    Put("X = " & Integer'Image(X) & "; and List = " & Image(List));
  42. >
  43.  
  44. Sloshing all those characters around unnecessarily gets a bit
  45. expensive after a while.  This expression is likely to copy the list
  46. image twice before it is actually output.
  47. -- 
  48. Kevin Cline
  49.